New Posts  All Forums:Forum Nav:

help with assembly?

post #1 of 4
Thread Starter 
Hi can anyone help me convert this C code to assembly? I am having some slight difficulties.

Code:
static unsigned char i, j, aResult[15]; /* Define Vars */
static const unsigned char aData[]={0xA0,0x1F,0xA5,0xB2,0x00} ; /* Define Data */
/* Initialize aResult array to all zeros */
for(i=0;i<15;i++){
aResult[i] = 0;
}
i=0; /* Set index for aData array */
while(aData[i] != 0){ /* While not EOS do */
if((aData[i]>= 0xA0) && (aData[i] <= 0xAF)) /* Check if between $A0 and $AF */
{ j = aData[i] ‐ 0xA0; /* if so, increment result array */
aResult[j]++;
}
i++; /* Look at next byte in aData array */
} /* End While loop */
So far I have this much but idk how much of it is right and idk how to finish it

Code:
LDX #aResult
LDAA #4 ;Number of bytes to clear
For: CLR 1,X+ ;Reg Index, post inc
DBNE A, FOR{
LDX #aData
While LDAA 1,X+ ;Reg INdex, Post Inc
BEQ END_WHILE{ ;Branch on Opposite
  IF: LDAA aData
CMPA $A0
(need to include and aData[i] <= $AF)
BLO ELSE{
SUBA, #A0
INCA
}
BRA END_IF
END_IF: {}
}
BRA While
}
END_WHILE:{}
   
Spare Rigs
(13 items)
 
CPUMotherboardGraphicsRAM
core 2 duo P8700@2.53GHz 2242CTO Intel X4500MHD 4gb 
Hard DriveOptical DriveOSMonitor
fujitsu 320gb dvd rom cd/rw Windows 7 Professional x64 15.4" 
PowerCaseMouse
Panasonic 6-cell + 65W AC adapter lenovo t500 Logitech MX518 
CPUMotherboardGraphicsRAM
Intel i5 760 evga p55 sli MSI gtx460 Hawk corsair dominator 
Hard DriveCoolingOSMonitor
kingston ssdnow hyper 212+ windows 7 professional sam syncmaster 
MonitorKeyboardPowerCase
Acer Razer Blackwidow ocz 650W coolermaster elite 335 
Mouse
Logitech MX518 
  hide details  
Reply
   
Spare Rigs
(13 items)
 
CPUMotherboardGraphicsRAM
core 2 duo P8700@2.53GHz 2242CTO Intel X4500MHD 4gb 
Hard DriveOptical DriveOSMonitor
fujitsu 320gb dvd rom cd/rw Windows 7 Professional x64 15.4" 
PowerCaseMouse
Panasonic 6-cell + 65W AC adapter lenovo t500 Logitech MX518 
CPUMotherboardGraphicsRAM
Intel i5 760 evga p55 sli MSI gtx460 Hawk corsair dominator 
Hard DriveCoolingOSMonitor
kingston ssdnow hyper 212+ windows 7 professional sam syncmaster 
MonitorKeyboardPowerCase
Acer Razer Blackwidow ocz 650W coolermaster elite 335 
Mouse
Logitech MX518 
  hide details  
Reply
post #2 of 4
You could cheat and compile it and then view the disassemble for it. Of course, it would be highly optimized and you probably would learn as much from it.
Foldatron
(17 items)
 
Mat
(10 items)
 
Work iMac
(9 items)
 
CPUMotherboardGraphicsGraphics
i7 950 EVGA x58 3-way SLI EVGA GTX 660ti GTX 275 
RAMHard DriveHard DriveHard Drive
3x2GB Corsair Dominator DDR3-1600 80GB Intel X25-M SSD 2TB WD Black 150GB WD Raptor 
Hard DriveOSMonitorKeyboard
2x 150GB WD V-raptor in RAID0 Win7 Home 64-bit OEM 55" LED 120hz 1080p Vizio MS Natural Ergonomic Keyboard 4000 
PowerCase
750W PC P&C Silencer CoolerMaster 690 
CPUGraphicsRAMHard Drive
Intel Core i5 2500S AMD 6770M 8GB (2x4GB) at 1333Mhz 1TB, 7200 rpm 
Optical DriveOSMonitorKeyboard
LG 8X Dual-Layer "SuperDrive" OS X Lion 27" iMac screen Mac wireless keyboard 
Mouse
Mac wireless mouse 
CPUGraphicsRAMHard Drive
i7-2600K AMD 6970M 1GB 16GB PC3-10600 DDR3 1TB 7200rpm 
Hard DriveOptical DriveOSMonitor
256GB SSD 8x DL "SuperDrive" OS X 10.7 Lion 27" 2560x1440 iMac display 
Monitor
27" Apple thunderbolt display 
  hide details  
Reply
Foldatron
(17 items)
 
Mat
(10 items)
 
Work iMac
(9 items)
 
CPUMotherboardGraphicsGraphics
i7 950 EVGA x58 3-way SLI EVGA GTX 660ti GTX 275 
RAMHard DriveHard DriveHard Drive
3x2GB Corsair Dominator DDR3-1600 80GB Intel X25-M SSD 2TB WD Black 150GB WD Raptor 
Hard DriveOSMonitorKeyboard
2x 150GB WD V-raptor in RAID0 Win7 Home 64-bit OEM 55" LED 120hz 1080p Vizio MS Natural Ergonomic Keyboard 4000 
PowerCase
750W PC P&C Silencer CoolerMaster 690 
CPUGraphicsRAMHard Drive
Intel Core i5 2500S AMD 6770M 8GB (2x4GB) at 1333Mhz 1TB, 7200 rpm 
Optical DriveOSMonitorKeyboard
LG 8X Dual-Layer "SuperDrive" OS X Lion 27" iMac screen Mac wireless keyboard 
Mouse
Mac wireless mouse 
CPUGraphicsRAMHard Drive
i7-2600K AMD 6970M 1GB 16GB PC3-10600 DDR3 1TB 7200rpm 
Hard DriveOptical DriveOSMonitor
256GB SSD 8x DL "SuperDrive" OS X 10.7 Lion 27" 2560x1440 iMac display 
Monitor
27" Apple thunderbolt display 
  hide details  
Reply
post #3 of 4
Thread Starter 
but the coding is excessive and some of it can be done in smaller amounts of coding
   
Spare Rigs
(13 items)
 
CPUMotherboardGraphicsRAM
core 2 duo P8700@2.53GHz 2242CTO Intel X4500MHD 4gb 
Hard DriveOptical DriveOSMonitor
fujitsu 320gb dvd rom cd/rw Windows 7 Professional x64 15.4" 
PowerCaseMouse
Panasonic 6-cell + 65W AC adapter lenovo t500 Logitech MX518 
CPUMotherboardGraphicsRAM
Intel i5 760 evga p55 sli MSI gtx460 Hawk corsair dominator 
Hard DriveCoolingOSMonitor
kingston ssdnow hyper 212+ windows 7 professional sam syncmaster 
MonitorKeyboardPowerCase
Acer Razer Blackwidow ocz 650W coolermaster elite 335 
Mouse
Logitech MX518 
  hide details  
Reply
   
Spare Rigs
(13 items)
 
CPUMotherboardGraphicsRAM
core 2 duo P8700@2.53GHz 2242CTO Intel X4500MHD 4gb 
Hard DriveOptical DriveOSMonitor
fujitsu 320gb dvd rom cd/rw Windows 7 Professional x64 15.4" 
PowerCaseMouse
Panasonic 6-cell + 65W AC adapter lenovo t500 Logitech MX518 
CPUMotherboardGraphicsRAM
Intel i5 760 evga p55 sli MSI gtx460 Hawk corsair dominator 
Hard DriveCoolingOSMonitor
kingston ssdnow hyper 212+ windows 7 professional sam syncmaster 
MonitorKeyboardPowerCase
Acer Razer Blackwidow ocz 650W coolermaster elite 335 
Mouse
Logitech MX518 
  hide details  
Reply
post #4 of 4
If you're having problems with that..... you need to study more!

Try doing the 8 Queens Problem in Assembly!
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
Once again...
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 [4.28GHz, HT] Asus P6T + Broadcom NetXtreme II VisionTek HD5850 [900/1200] + Galaxy GT240 2x4GB G.Skill Ripjaw X [1632 MHz] 
Hard DriveOSMonitorKeyboard
Intel X25-M 160GB + 3xRAID0 500GB 7200.12 Window 7 Pro 64 Acer H243H + Samsung 226BW XARMOR-U9BL  
PowerCaseMouseMouse Pad
Antec Truepower New 750W Li Lian PC-V2100 [10x120mm fans] Logitech G9 X-Trac Pro 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming