Author Topic: JSON Parser  (Read 210 times)

iguananed

  • Regular Member
  • *
  • Posts: 3
JSON Parser
« on: June 20, 2018, 06:43:43 AM »
Just started my dabbling in MASM32 trying to determine if I will be able to develop my next application wioth it.

I am looking at making a High speed middle-ware application which will interface two systems using REST.

I have not found any examples of using MASM32 to parse JSON.

any help you be appreciated.

Raistlin

  • Member
  • ***
  • Posts: 353
Re: JSON Parser
« Reply #1 on: June 20, 2018, 07:03:25 AM »
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

jj2007

  • Member
  • *****
  • Posts: 8501
  • Assembler is fun ;-)
    • MasmBasic
Re: JSON Parser
« Reply #2 on: June 20, 2018, 08:35:13 AM »
Interesting link, Raistlin. Some clicks further is a SOF article on the SSE4.2 string functions. like pcmpistrm and pcmpestrm, with some surprises.

iguananed

  • Regular Member
  • *
  • Posts: 3
Re: JSON Parser
« Reply #3 on: June 21, 2018, 01:38:05 AM »
Really hard to believe you haven't seen any.
Assembly using SSE is all the rage for JSON.
see: https://amp-reddit-com.cdn.ampproject.org/v/s/amp.reddit.com/r/programming/comments/3pojrz/the_fastest_json_parser_in_the_world/?amp_js_v=a1&amp_gsa=1&usqp=mq331AQCCAE%3D#referrer=

Sorry I should have been a bit more specific. I have not seen any Source code examples or libraries.

I am looking for something like this the following but for MASM32,  https://2ton.com.au/library_as_html/json.inc.html


Raistlin

  • Member
  • ***
  • Posts: 353
Re: JSON Parser
« Reply #4 on: June 21, 2018, 02:44:25 AM »
Right, so that's a 64-bit library that does what you want.(link)
What's the problem then ? Not optimized ? Not enough SSE ?
AVX interesting ? The person that wrote it is not a native ASM
personage and missed a crap load of obvious cool stuff?

Now I (we, sorry guys I am being presumptive) need to know, do you have ASM expierence and want to write this? Or are you
waiting (hoping) someone has or will take up
the project ? This is sort of what it boils down
to. No effort on your part = no gain. There are
some serious weirdo SSE\AVX nuts (ppl) on
this forum. But why would they not just write the
commercial middleware themselves or consider
helping you without real effort (not copy & paste (c)).

Please understand the situation you are describing
« Last Edit: June 21, 2018, 06:12:38 AM by Raistlin »
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

iguananed

  • Regular Member
  • *
  • Posts: 3
Re: JSON Parser
« Reply #5 on: June 21, 2018, 06:45:24 AM »
I have very little(none)  ASM experience. Just did not want to re invent the wheel. I figured it was something that might have already been done.

Raistlin

  • Member
  • ***
  • Posts: 353
Re: JSON Parser
« Reply #6 on: June 21, 2018, 07:10:38 AM »
Really well done young padewan. Seriously = No, that 64-bit lib looks suspect. I have had the privilege of seeing god-like SSE
and 64-bit code in my lifetime. Where? Right here on the forum.

The thing is, no one here will write code for you, ever. The end. They will however painstakingly help you with your code....
ASM is the BEST, but you probably know that already. The
fastest & smallest & sexy-ist code & most difficult to unlearn in the world (probably universe) = assembly. Absolute perfection
is always around the corner. Believe me, I am still hunting

BTW: We reinvent the wheel here on a daily basis. The wheels produced here, are from time to time the
subject of  international peer reviewed research papers,.
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

2ton

  • Regular Member
  • *
  • Posts: 2
Re: JSON Parser
« Reply #7 on: June 21, 2018, 07:58:02 AM »
Seriously = No, that 64-bit lib looks suspect.
Author of said lib chiming in, curious as to why you think it is suspect. (As mentioned elsewhere, it is general purpose and <= SSE2 quite intentionally, and GPL).

Cheers

Raistlin

  • Member
  • ***
  • Posts: 353
Re: JSON Parser
« Reply #8 on: June 21, 2018, 08:19:27 AM »
@2ton: Doubtfull. Copy and paste original source & we might
talk.(PM if you want). What  has GPL have to do with anything around the conversation. Doesn't make for better code, or is that
an invite? The belief is there is sub optimum SSE instruction
usage blatantly evident in the perused (prompently copyrighted) library, that no-one seemingly knew about. Until posted here that is.... suspect

My opinion is mine, asked for and answered. If you disagree,
so be it.. Find someone else to help.....
Are you pondering what I'm pondering? It's time to take over the world ! - let's use ASSEMBLY...

jj2007

  • Member
  • *****
  • Posts: 8501
  • Assembler is fun ;-)
    • MasmBasic
Re: JSON Parser
« Reply #9 on: June 21, 2018, 08:48:14 AM »
@2ton: Doubtfull. Copy and paste original source

It seems this page is indeed the original source.

2ton

  • Regular Member
  • *
  • Posts: 2
Re: JSON Parser
« Reply #10 on: June 21, 2018, 08:48:44 AM »
Doubtful of what?

An example of using my library to deal with JSON:
Code: [Select]
include 'ht/ht_defaults.inc'
include 'ht/ht.inc'

public _start
_start:
; initialise the library
call ht$init
; simple case: create a new named json object
mov rdi, .oname
call json$newobject
mov rbx, rax
mov rdi, rax
call json$tostring
mov r12, rax
mov rdi, rax
call string$to_stdoutln
mov rdi, r12
call heap$free
mov rdi, rbx
call json$destroy

; next case: parse json
mov rdi, .jtext
xor esi, esi
call json$parse_object
; turn that back into a string
mov rbx, rax
mov rdi, rax
call json$tostring
mov r12, rax
mov rdi, rax
call string$to_stdoutln
mov rdi, r12
call heap$free
mov rdi, rbx
call json$destroy

; bailout
mov eax, syscall_exit
xor edi, edi
syscall
cleartext .oname, 'ObjectName'
cleartext .jtext, '{"varone":true,"vartwo":"string","varthree":1.553,"varfour":[1,2,3,4,5,6,7,8,9],"varfive":{"subvarone":"Heya"}}'

include 'ht/ht_data.inc'

When run, it outputs
Code: [Select]
"ObjectName":{}
{"varone":true,"vartwo":"string","varthree":1.553,"varfour":[1,2,3,4,5,6,7,8,9],"varfive":{"subvarone":"Heya"}}

fearless

  • Member
  • ***
  • Posts: 321
    • LetTheLightIn
Re: JSON Parser
« Reply #11 on: June 21, 2018, 10:35:25 AM »
Could just use an existing json library

http://www.digip.org/jansson/
or
https://github.com/DaveGamble/cJSON
I have some precompiled libs for those in x86 and x64 with masm style includes:

- https://github.com/mrfearless/libraries/tree/master/Jansson
- https://github.com/mrfearless/libraries/tree/master/cJSON
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

www.LetTheLight.in  My Github  Twitter